function bi = dec2bin(de, biNum)
  if size(de,2) ~= 1
    error('input decimal must be a number or a column vector');
  end
  if int(de) ~= de | min(de) < 0
    error('input number must be positive integer')
  end

  [lhs, rhs] = argn();
  if rhs < 2  //biNum is not specified
    maxNum = max(de);
    biNum = floor(log2(maxNum)+1);
  end
  if biNum <= 0 | int(biNum) ~= biNum
    error('bit number must be a positive integer');
  end
  
  len = size(de,1);
  bi = zeros(len, biNum);

  for j = 1:biNum
    bi(:,j) = modulo(de,2);
    de = int(de/2);
  end
endfunction

